package com.qifenqian.turbot.module.dialog

import android.os.Bundle
import android.view.View
import com.qifenqian.turbot.R
import com.qifenqian.turbot.base.BaseDialogFragment
import kotlinx.android.synthetic.main.dialog_example_image.view.*

/**
 * @author H
 * @createTime 2019/1/2 18:02
 * @description
 * @see
 * @since
 */
const val EXAMPLE_TYPE = "exampleType"

const val TYPE_EXAMPLE_ID_CARD = 0x700          //身份证
const val TYPE_EXAMPLE_SERVICE_LICENCE = 0x701  //餐饮服务许可证
const val TYPE_EXAMPLE_BUSINESS_LICENCE = 0x702 //营业执照
const val TYPE_EXAMPLE_RESTAURANT_PHOTO = 0x703 //照片

class ExampleImageDialog : BaseDialogFragment() {

    companion object {
        fun newInstance(exampleType: Int): ExampleImageDialog {
            val exampleImageDialog = ExampleImageDialog()
            val bundle = Bundle()
            bundle.putInt(EXAMPLE_TYPE, exampleType)
            exampleImageDialog.arguments = bundle
            return exampleImageDialog
        }
    }

    private var mExampleType: Int = 0
    override fun loadData(bundle: Bundle?) {
        if (bundle != null) {
            mExampleType = bundle.getInt(EXAMPLE_TYPE)
        }
    }

    override fun bindLayoutId(): Int {
        return R.layout.dialog_example_image
    }

    override fun initView(view: View) {
        when (mExampleType) {
            TYPE_EXAMPLE_ID_CARD          -> {
                view.iv_dialog_example_image1.visibility = View.VISIBLE
                view.iv_dialog_example_image2.visibility = View.VISIBLE
                view.iv_dialog_example_image3.visibility = View.GONE
                view.iv_dialog_example_image1.setImageResource(R.mipmap.ic_verify_default)
                view.iv_dialog_example_image2.setImageResource(R.mipmap.ic_verify_default)
            }
            TYPE_EXAMPLE_SERVICE_LICENCE  -> {
                view.iv_dialog_example_image1.visibility = View.VISIBLE
                view.iv_dialog_example_image2.visibility = View.GONE
                view.iv_dialog_example_image3.visibility = View.GONE
                view.iv_dialog_example_image1.setImageResource(R.mipmap.ic_verify_default)
            }
            TYPE_EXAMPLE_BUSINESS_LICENCE -> {
                view.iv_dialog_example_image1.visibility = View.VISIBLE
                view.iv_dialog_example_image2.visibility = View.GONE
                view.iv_dialog_example_image3.visibility = View.GONE
                view.iv_dialog_example_image1.setImageResource(R.mipmap.ic_verify_default)
            }
            TYPE_EXAMPLE_RESTAURANT_PHOTO -> {
                view.iv_dialog_example_image1.visibility = View.VISIBLE
                view.iv_dialog_example_image2.visibility = View.VISIBLE
                view.iv_dialog_example_image3.visibility = View.VISIBLE
                view.iv_dialog_example_image1.setImageResource(R.mipmap.ic_verify_default)
                view.iv_dialog_example_image2.setImageResource(R.mipmap.ic_verify_default)
                view.iv_dialog_example_image3.setImageResource(R.mipmap.ic_verify_default)
            }
        }
        view.btn_dialog_example_image_close.setOnClickListener {
            dialog.dismiss()
        }
    }
}